package com.chenqq.qsocket.handler;


import com.chenqq.qsocket.message.SocketMessage;
import com.chenqq.qsocket.tools.LogShow;

public class MessageHandlerFactory {
    public static MessageHandler getHandler(int type) {
        MessageHandler handler = null;
        switch (type) {
            case SocketMessage.TYPE_REQUEST_SEND_FILE:
                handler = new RequestSendFileMessageHandler();
                break;
            case SocketMessage.TYPE_ACCEPT_RECEIVE_FILE:
                handler = new AcceptReceiveFileMessageHandler();
                break;
            case SocketMessage.TYPE_SEND_FILE_PART:
                handler = new SendFilePartMessageHandler();
                break;
            case SocketMessage.TYPE_RECEIVE_FILE_PART:
                handler = new ReceiveFileFinishMessageHandler();
                break;
            case SocketMessage.TYPE_REFUSE_RECEIVE_FILE:
                handler=new RefuseReceiveFileMessageHandler();
                break;
            case SocketMessage.TYPE_SEND_TEXT:
            case SocketMessage.TYPE_SEND_TEXT_HEX:
                handler = new MessageInfoHandler();
                break;
            case SocketMessage.TYPE_HEART_BEAT:
                handler = new AliveMessageHandler();
                break;

        }
        LogShow.showV("接受文件" + type + "  handler==null " + (handler == null));
        return handler;
    }
}
